home *** CD-ROM | disk | FTP | other *** search
- /*
- ### matrix memory allocation ###
- */
-
- double **dmatrix(nrl,nrh,ncl,nch)
- int nrl,nrh,ncl,nch;
- {
- int i;
- double **m;
- void free_dmatrix();
-
- m = (double **) malloc((unsigned) (nrh - nrl + 1) * sizeof(double *));
- if(!m) {
- system_mess_proc(1,"dmatrix: memory allocation failure!");
- return(0);
- }
- else {
- m -= nrl;
- }
-
- for(i=nrl;i<=nrh;i++){
- m[i] = (double *) malloc((unsigned) (nch - ncl + 1) * sizeof(double));
- if(!m[i]) {
- system_mess_proc(1,"dmatrix: memory allocation failure!");
- free_dmatrix(m,nrl,i-1,ncl,nch);
- return(0);
- }
- else {
- m[i] -= ncl;
- }
- }
- return(m);
- }
-